{% extends 'base.html' %}
{% block main %}
    {% load blog_tags %}
    <div class="content-wrap">
        <div id="content" class="content">
            <section id="posts" class="posts-collapse">
                <span class="archive-move-on"></span>
                <span class="archive-page-counter">非常好! 目前共计 {% total_posts %} 篇日志。 继续努力。</span>
                {% regroup posts by publish.year as grouped %}
                    {% for post in grouped %}
                        <div class="collection-title">
                            <h2 class="archive-year motion-element" id="archive-year-{{ post.grouper }}">{{ post.grouper }}</h2>
                        </div>
                        {% for post in post.list %}
                            <article class="post post-type-normal">
                            <header class="post-header">
                                <h1 class="post-title">
                                    <a class="post-title-link" href="{{ post.get_absolute_url }}">
                                        <span>{{ post.title }}</span>
                                    </a>
                                </h1>
                                <div class="post-meta">
                                    <time class="post-time" datetime="{{ post.publish}}"
                                          content="{{ post.publish|date:'Y-m-d' }}">
                                        {{ post.publish|date:'m-d' }}
                                    </time>
                                </div>
                            </header>
                        </article>
                    {% endfor %}
                {% endfor %}
            </section>
            {% if is_paginated %}
                <nav class="pagination">
                    {% if page_obj.has_previous %}
                        <a class="extend prev" rel="prev" href="?page={{ page_obj.previous_page_number }}"><i
                                class="fa fa-angle-left"></i></a>
                    {% endif %}
                    {% if first %}
                        <span class="page-number" href="?page=1">1</span>
                    {% endif %}
                    {% if left %}
                        {% if left_has_more %}
                            <span class="space">…</span>
                        {% endif %}
                        {% for i in left %}
                            <a class="page-number" href="?page={{ i }}">{{ i }}</a>
                        {% endfor %}
                    {% endif %}
                    <span class="page-number current">{{ page_obj.number }}</span>
                    {% if right %}
                        {% for i in right %}
                            <a class="page-number" href="?page={{ i }}">{{ i }}</a>
                        {% endfor %}
                        {% if right_has_more %}
                            <span class="space">…</span>
                        {% endif %}
                    {% endif %}
                    {% if last %}
                        <a class="page-number" href="?page={{ paginator.num_pages }}">{{ paginator.num_pages }}</a>
                    {% endif %}
                    {% if page_obj.has_next %}
                        <a class="extend next" rel="next" href="?page={{ page_obj.next_page_number }}"><i
                                class="fa fa-angle-right"></i></a>
                    {% endif %}

                </nav>
            {% endif %}
        </div>
    </div>
{% endblock %}
{% block script %}
    <script type="text/javascript" id="motion.page.archive">
      $('.archive-year').velocity('transition.slideLeftIn');
    </script>
{% endblock %}